package cn.jsj.finance.bank;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 银行帐报表查看处理类
 * @author LI
 *
 */
 public class FinanceReportForm extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		 // 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("报表信息查看！！！");

		 //获得报表种类和具体时间
		 String catalogName=request.getParameter("catalog");
		 String detailTime=request.getParameter("time");

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("获得的参数为----------->"+catalogName+"   "+detailTime);

		 //新建参数类
		 cn.jsj.bgtodb.ReportForm rf=new cn.jsj.bgtodb.ReportForm();
		 rf.setCatalogName(catalogName);
		 rf.setDetailTime(detailTime);

		 //查看报表信息
		 cn.jsj.dao.TblBankAccountDAO tbad=new cn.jsj.dao.TblBankAccountDAO();
		 String reportInfo=tbad.getReportFormData(rf);

		 //要返回的字符串
		 String returnString="";
		 //判断是否为NULL
		 if(reportInfo.equalsIgnoreCase("0")){
			 returnString="0,0,0";
		 }
		 else{
			 //划分字符串
			 String[] str=reportInfo.split(",");
			 //获得收入支出总数
			 int income=Integer.parseInt(str[0].trim());
			 int payout=Integer.parseInt(str[1].trim());

			 //求出余额
			 int leaveMoney=income-payout;
			 //拼接成字符串返回给客户端
			 returnString=income+","+payout+","+leaveMoney;
			 //调试信息
			 cn.jsj.utils.SysLogger.PrintInfo("jiegou------------>"+returnString);
		 }
		 //输出流
		 java.io.PrintWriter out=response.getWriter();
		 out.println("{message:'"+returnString+"'}");
		 out.flush();
	}
}